package com.neusoft.lohas.modules.ivm.entity.order;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.neusoft.lohas.common.persistence.IdEntity;
import com.neusoft.lohas.modules.ivm.entity.merchant.Merchant;

/**
 * 商品订单折扣Entity
 * @author Jackie.Liu
 * @version 2014-12-16
 */
@Entity
@Table(name = "ivm_order_discount")
@DynamicInsert @DynamicUpdate
public class OrderDiscount extends IdEntity<OrderDiscount>{

	private static final long serialVersionUID = 1L;
	private Merchant merchant; //所属商户
	private String code; //折扣码
	private double rate; //折扣率
	
	public OrderDiscount() {
		super();
	}

	public OrderDiscount(String id){
		this();
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="merchant_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="归属商户不能为空")
	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public double getRate() {
		return rate;
	}

	public void setRate(double rate) {
		this.rate = rate;
	}
	
	
}
